package org.nemanjaristic.utils;

import java.util.ArrayList;
import java.util.List;

public class StringUtils {

	public static List<String> splitByUsualSeparator(String text) {
		if (text == null)
			return null;

		if (text.isEmpty())
			return new ArrayList<String>(1);

		String splitChar = ";";
		if (text.contains("|"))
			splitChar = "\\|";
		else if (text.contains(";"))
			splitChar = ";";
		else
			splitChar = ",";

		String[] items = text.split(splitChar);

		List<String> parts = new ArrayList<String>(items.length);

		for (String item : items)
			if (item != null && !item.isEmpty())
				parts.add(item.trim());

		return parts;
	}
}
